/*
* Authoer:JacksonCoder
* CreateTime:
* Version: 1.0.0
*/
use std::intrinsics::atomic_nand_acqrel;

// This is the main function, the entry point of the Rust program
const PI: f32 = 3.1415926;
// Declare a variable x with value 5 (immutable by default)

fn main() {
    // Declare a mutable variable y with value 8
    let x = 5;

    // Print the value of x
    let mut y = 8;
    // Print the value of y

    println!("x 的值为:{}", x);
    // Change the value of y to 10 since it's declared as mutable
    println!("y 的值为:{}", y);
    // Print the new value of y

    y = 10;
    println!("y 的值为:{}", y);

    println!("常量PI = {}", PI);

    // 遮蔽
    let n = 10;
    let n = n + 1;

    {
        let n = n * 2;
        println!("内层的 n:{}", n);
    }

    println!("外层的 n 值为:{}", n);

    // 基本数据类型
    let q = 2.0;
    let p: f32 = 3.0;
    println!("q = {} , p = {} ", q, p);

    let t = true;
    let f: bool = false;
    if t {
        println!("真");
    }

    let c = 'c';
    let z: char = 'Z';
    let heart_eyed_cat = '😻';
    println!("字符:{}", heart_eyed_cat);

    // 符合类型
    let tup: (i32, f64, u8) = (500, 6.4, 1);
    let (x, y, z) = tup; // 解构
    println!("y 的值为:{}", y);
    let five_hundred = tup.0; // 索引访问

    let a: [i32; 5] = [1, 2, 3, 4, 5];
    let b = [3; 5]; // [3,3,3,3,3]
    println!("第一个元素:{}", a[0]);

    println!("这里是main函数");
    another_function();

    println!("======= 带参函数 =======");
    with_params(10, 'b');

    println!("======= 带返回值函数 =======");
    return_function(900);
}

fn return_function(x: i32) -> i32 {
    x + 20;
}

fn with_params(value: i32, b: char) {
    println!("第一个参数值为:{}, 第二个参数值为:{}", value, b);
}
fn another_function() {
    println!("另一个函数");
}
